package com.cai.servlet.common.topic;

import com.cai.dao.DetailedTopicDao;
import com.cai.dao.impl.DetailedTopicDaoImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author RuoLi
 */
@WebServlet(name = "ServletDetailedTopicDelete", value = "/common/detailedTopicDelete")
public class ServletDetailedTopicDelete extends HttpServlet {
    DetailedTopicDao detailedTopicDao = new DetailedTopicDaoImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        //获取参数
        int detailedTopicId = Integer.parseInt(req.getParameter("DetailedTopicId"));
        int status = detailedTopicDao.deleteDetailedTopic(detailedTopicId);
        if (status != -1) {
            resp.getWriter().write(status);
        } else {
            resp.getWriter().write(status);
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }
}
